package com.teangtang.fly.service;

import com.teangtang.fly.entity.Province;
import com.teangtang.fly.repository.ProvinceRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ProvinceService {
    @Autowired
    private ProvinceRepository provinceRepository;

    public Province saveProvince(Province province) {
        return provinceRepository.save(province);
    }

    public List<Province> findAllProvinces() {
        return provinceRepository.findAll();
    }

    public Province findProvinceById(Long provinceCode) {
        return provinceRepository.findById(provinceCode).orElse(null);
    }

    public void deleteProvince(Long provinceCode) {
        provinceRepository.deleteById(provinceCode);
    }
}
